home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / BC_TI.ARJ / TI707.ASC < prev    next >
Text File  |  1992-02-25  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C++                            NUMBER  :  707
  9.   VERSION  :  2.0
  10.        OS  :  DOS
  11.      DATE  :  February 25, 1992                        PAGE  :  1/2
  12.  
  13.     TITLE  :  Linking Third Party BGI Drivers
  14.  
  15.  
  16.  
  17.  
  18.   /*************************************************************
  19.   This document explains how to link third party graphics drivers
  20.   into your program.  This example is specific to the vga256.bgi
  21.   driver which is available on the Borland BBS (408) 439-9096.  The
  22.   procedure is the same to link in one of the drivers that was
  23.   shipped with your product except that  you don't need to make the
  24.   call to installuserdriver() function which means that you also
  25.   don't need the alwayszero() function.
  26.  
  27.      1.  Convert vga256.bgi to an object file with this command:
  28.  
  29.          BGIOBJ vga256.bgi vga256.obj _vga256_driver
  30.  
  31.      2.  Create a project file for the program that links in the
  32.          driver.  The project should contain two items:
  33.  
  34.                  A.  test.c
  35.                  B.  vga256.obj
  36.  
  37.      3.  Here's what test.c would look like:
  38.  
  39.   ************************************************************/
  40.  
  41.   #include <graphics.h>
  42.   #include <stdlib.h>
  43.   #include <stdio.h>
  44.   #include <conio.h>
  45.  
  46.   /* function prototypes */
  47.   int huge alwayszero(void);
  48.   void checkerrors(void);
  49.   void  _Cdecl vga256_driver(void);
  50.  
  51.  
  52.   int main(void)
  53.   {
  54.      int gdriver, gmode;
  55.  
  56.      /* install the user defined driver into the system */
  57.      gdriver = installuserdriver("vga256", alwayszero);
  58.  
  59.      /* check for any installation errors */
  60.      checkerrors();
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C++                            NUMBER  :  707
  75.   VERSION  :  2.0
  76.        OS  :  DOS
  77.      DATE  :  February 25, 1992                        PAGE  :  2/2
  78.  
  79.     TITLE  :  Linking Third Party BGI Drivers
  80.  
  81.  
  82.  
  83.  
  84.      /* register the driver with the graphics system */
  85.      registerbgidriver(vga256_driver);
  86.  
  87.      /* check for any installation errors */
  88.      checkerrors();
  89.  
  90.      /* initialize graphics and local variables */
  91.      initgraph(&gdriver, &gmode, "");
  92.  
  93.      /* check for any initialization errors */
  94.      checkerrors();
  95.  
  96.      /* draw a line */
  97.      setcolor(WHITE);
  98.      line(0, 0, getmaxx(), getmaxy());
  99.  
  100.      /* clean up */
  101.      getch();
  102.      closegraph();
  103.      return 0;
  104.   }
  105.  
  106.   int huge alwayszero(void)
  107.   {
  108.         return 0;
  109.   }
  110.  
  111.   /* check for and report any graphics errors */
  112.   void checkerrors(void)
  113.   {
  114.      int errorcode;
  115.  
  116.      /* read result of last graphics operation */
  117.      errorcode = graphresult();
  118.      if (errorcode != grOk)
  119.      {
  120.         printf("Graphics error: %s\n", grapherrormsg(errorcode));
  121.         printf("Press any key to halt:");
  122.         getch();
  123.         exit(1);
  124.      }
  125.   }
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.